from game_agent import GameAgent
from linear import linearEvaluator
from anytime_alpha_beta_extended import AnyTimeAlphaBetaSearch_Extended, INFINITY

#Face =      AgentEnglish(   3   ,   6   ,   4   ,   2   ,   6)
class copmetitionAgent(GameAgent):
    '''
    AnyTimeAlphaBetaNoImp
    utility: linearEvaluator
    '''
    def __init__(self,  neighborWeight_ = 3,\
                        diagQuadWeight_ = 6,\
                        threeQuadWeight_ = 4,\
                        squareQuadWeight_ = 2,\
                        areaExp_ = 6):
        self.neighborWeight = neighborWeight_
        self.diagQuadWeight = diagQuadWeight_
        self.threeQuadWeight = threeQuadWeight_
        self.squareQuadWeight = squareQuadWeight_
        self.areaExp = areaExp_
        
    def move(self, game_state):
        return self.alphaBeta.search(game_state)
    
    def setup(self, player, game_state, turn_time_limit, setup_time_limit):
        self.player = player
        self.prevUtil = -INFINITY
        u = lambda state, endTime: self.utility(state, endTime)
        self.alphaBeta = AnyTimeAlphaBetaSearch_Extended(self.player, 3, u, turn_time_limit, game_state)
    
    def utility(self, state, endTime):
        return linearEvaluator(self, state, self.player,\
                               self.neighborWeight,\
                               self.diagQuadWeight,\
                               self.threeQuadWeight,\
                               self.squareQuadWeight,\
                               self.areaExp,\
                               endTime)